{% extends 'WebQuant/base.html' %}
{% block title %}收益概况{% endblock %}
{% block content %}
{% include 'WebQuant/deal_nav.html' %}
<div class="leftmask"></div>
{% include 'WebQuant/deal_nav_left.html' %}
<div class="right_cont">
    <div class="clouddeal" >
        <div class="cont_head">
            <div class="moudle_top">
                <div>日期：<span class="date">{{deal_info.begin_date}} -- {{deal_info.update_date}} </span></div><span class="duandian">|</span>
                <div>证券市值：<span class="initial">{{deal_info.market_value}}</span></div><span class="duandian">|</span>
                <div>剩余资金：<span class="daily">{{deal_info.cash}}</span></div><span class="duandian">|</span>
                {% if deal_info.state == 0 %}
                    <div>状态：<span class="time" id="deal_status">运行中(开市)</span></div>
                    <div class="stopdeal_btn" >终止</div>
                {% else %}
                    <div>状态：<span class="time" id="deal_status">已终止(闭市)</span></div>
                {% endif %}
            </div>
            <div class="deal_head">最新持仓<span>（更新于{{deal_info.update_date}} {{deal_info.update_time}}）</span></div>
            <div class="lastcc">
                <div class="list">
                    <div class="listborder">
                        <div class="listhead">
                            <span class="col1">股票代码</span>
                            <span class="col2">股票名称</span>
                            <span class="col3">最新价格(元)</span>
                            <span class="col4">股数</span>
                            <span class="col5">市值</span>
                            <span class="col6">收益</span>
                        </div>
                        <ul class="listborder_bottom">
                            {% for position in deal_info.position_list %}
                            <li>
                                <span class="col1">{{position.stock_code}}</span>
                                <span class="col2">{{position.stock_name}}</span>
                                <span class="col3">{{position.close}}</span>
                                <span class="col4">{{position.quantity}}</span>
                                <span class="col5">{{position.market_value}}</span>
                                {% if position.return_field < 0%}
                                    <span class="col6" id="c_green">{{position.return_field}}</span>
                                {% else %}
                                    <span class="col6" id="c_red">{{position.return_field}}</span>
                                {% endif %}
                            </li>
                            {% endfor %}
                        </ul>
                    </div>
                </div>
            </div>
            <div class="deal_head">收益详情<span>（更新于{{deal_info.update_date}} {{deal_info.update_time}}）</span></div>
            <div class="sy_data">
                <div class="line1">
                    <span class="col1">累计收益率</span>
                    <span class="col2">年化收益率</span>
                    <span class="col3">基准收益</span>
                    <span class="col4">基准年化收益</span>
                    <span class="col5">夏普比率</span>
                    <span class="col6">最大回撤</span>
                </div> 
                <div class="line2">
                    {% if deal_info.total_return %}
                        {% if deal_info.total_return < 0 %}
                            <span class="col1" id="c_green">{{deal_info.total_return}}%</span>
                        {% else %}
                            <span class="col1" id="c_red">{{deal_info.total_return}}%</span>
                        {% endif %}
                    {% else %}
                        <span class="col1" >--</span>
                    {% endif %}

                    {% if deal_info.annual_return %}
                        {% if deal_info.annual_return < 0 %}
                            <span class="col2" id="c_green">{{deal_info.annual_return}}%</span>
                        {% else %}
                            <span class="col2" id="c_red">{{deal_info.annual_return}}%</span>
                        {% endif %}
                    {% else %}
                        <span class="col2" >--</span>
                    {% endif %}

                    {% if deal_info.benchmark %}
                        {% if deal_info.benchmark < 0 %}
                            <span class="col3" id="c_green">{{deal_info.benchmark}}%</span>
                        {% else %}
                            <span class="col3" id="c_red">{{deal_info.benchmark}}%</span>
                        {% endif %}
                    {% else %}
                        <span class="col3" >--</span>
                    {% endif %}

                    {% if deal_info.benchmark_annual_return %}
                        {% if deal_info.benchmark_annual_return < 0 %}
                            <span class="col4" id="c_green">{{deal_info.benchmark_annual_return}}%</span>
                        {% else %}
                            <span class="col4" id="c_red">{{deal_info.benchmark_annual_return}}%</span>
                        {% endif %}
                    {% else %}
                        <span class="col4" >--</span>
                    {% endif %}

                    {% if deal_info.sharpe %}
                        {% if deal_info.sharpe < 0 %}
                            <span class="col5" id="c_green">{{deal_info.sharpe}}%</span>
                        {% else %}
                            <span class="col5" id="c_red">{{deal_info.sharpe}}%</span>
                        {% endif %}
                    {% else %}
                        <span class="col5" >--</span>
                    {% endif %}

                    {% if deal_info.max_drew_down %}
                        {% if deal_info.max_drew_down < 0 %}
                            <span class="col6" id="c_green">{{deal_info.max_drew_down}}%</span>
                        {% else %}
                            <span class="col6" id="c_red">{{deal_info.max_drew_down}}%</span>
                        {% endif %}
                    {% else %}
                        <span class="col6" >--</span>
                    {% endif %}

                </div>
            </div>
            <div class="chart">
                <div id="main" style="min-width:400px;height:400px;padding-top:13px"></div>
            </div>
        </div>
    </div>
</div>
<div class="mask"></div>
<div class="pannel1 custom_color">
    <p><span class="tip">模拟交易终止后将无法再重启，确认要终止吗？</span></p>
    <input type="button" value="取消" class="no">
    <input type="button" value="确定" class="yes" onclick="on_stop_deal()">
</div>
<!-- <script src="/static/WebQuant/js/echarts.min.js"></script> -->
<script src="/static/WebQuant/js/hstock/highstock.js"></script>
<script src="/static/WebQuant/js/hstock/exporting.js"></script>
<script src="/static/WebQuant/js/csrf.js"></script>
<script src="/static/WebQuant/js/deal_back_test.js"></script>
<script>
    $(".stopdeal_btn").click(function(){
        $(".pannel1").show();
        $(".mask").show();
    })
    $(".no").click(function() {
        $(".pannel1").hide();
        $(".mask").hide();

    });
</script>
{% endblock %}